package com.cpd.blog.controller;

import com.cpd.blog.dto.Result;
import com.cpd.blog.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 标签接口
 *
 * @author Copydown
 * @date 2021/8/16 16:03
 */
@Api(tags = "文章标签模块")
@RestController
@RequestMapping("tags")
@RequiredArgsConstructor
public class TagsController {

    private final TagService tagService;

    @ApiOperation(value = "最热标签 接口")
    @GetMapping("/hot")
    public Result hot() {
        int limit = 6;
        return tagService.hots(limit);
    }

    @ApiOperation(value = "所有标签 接口")
    @GetMapping
    public Result findAll() {
        return tagService.findAll();
    }

    @ApiOperation(value = "所有标签详情 接口")
    @GetMapping("detail")
    public Result findAllDetail() {
        return tagService.findAllDetail();
    }

    @ApiOperation(value = "搜索标签详情 接口")
    @GetMapping("detail/{id}")
    public Result findDetailById(@PathVariable("id") Long id) {
        return tagService.findDetailById(id);
    }
}
